/*
'===============================================================================
'  Generated From - CSharp_EasyObject_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL      = SQL_DAAB_StoredProcs.vbgen
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easily done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  public class YourObject :  _YourObject
'  {
'
'  }
'
'===============================================================================
*/

// Generated by MyGeneration Version # (1.3.0.3)

using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Xml;
using System.IO;

using Microsoft.Practices.EnterpriseLibrary.Data;
using NCI.EasyObjects;

namespace CMS.DAL
{

	#region Schema

	public class AdvSchema : NCI.EasyObjects.Schema
	{
		private static ArrayList _entries;
		public static SchemaItem AdvID = new SchemaItem("AdvID", DbType.Int32, true, false, false, true, false, false);
		public static SchemaItem PartnerName = new SchemaItem("PartnerName", DbType.String, SchemaItemJustify.None, 250, true, false, false, false);
		public static SchemaItem Description = new SchemaItem("Description", DbType.String, SchemaItemJustify.None, 1073741823, true, false, false, false);
		public static SchemaItem AdvURL = new SchemaItem("AdvURL", DbType.String, SchemaItemJustify.None, 250, true, false, false, false);
		public static SchemaItem AdvFile = new SchemaItem("AdvFile", DbType.String, SchemaItemJustify.None, 250, false, false, false, false);
		public static SchemaItem AdvTypeID = new SchemaItem("AdvTypeID", DbType.Int32, false, false, false, false, false, false);
		public static SchemaItem AdvPositionID = new SchemaItem("AdvPositionID", DbType.Int32, false, false, false, false, false, false);
		public static SchemaItem Status = new SchemaItem("Status", DbType.Int32, false, false, false, false, false, false);
		public static SchemaItem Priority = new SchemaItem("Priority", DbType.Int32, false, true, false, false, false, false);
		public static SchemaItem CreatedDate = new SchemaItem("CreatedDate", DbType.Int32, false, true, false, false, false, false);
		public static SchemaItem ExpiredDate = new SchemaItem("ExpiredDate", DbType.Int32, false, true, false, false, false, false);

		public override ArrayList SchemaEntries
		{
			get
			{
				if (_entries == null )
				{
					_entries = new ArrayList();
					_entries.Add(AdvSchema.AdvID);
					_entries.Add(AdvSchema.PartnerName);
					_entries.Add(AdvSchema.Description);
					_entries.Add(AdvSchema.AdvURL);
					_entries.Add(AdvSchema.AdvFile);
					_entries.Add(AdvSchema.AdvTypeID);
					_entries.Add(AdvSchema.AdvPositionID);
					_entries.Add(AdvSchema.Status);
					_entries.Add(AdvSchema.Priority);
					_entries.Add(AdvSchema.CreatedDate);
					_entries.Add(AdvSchema.ExpiredDate);
				}
				return _entries;
			}
		}
		
		public static bool HasAutoKey 
		{
			get { return true;	}
		}

		public static bool HasRowID 
		{
			get { return false;	}
		}
	}
	#endregion

	public abstract class _Adv : EasyObject
	{

		public _Adv()
		{
			AdvSchema _schema = new AdvSchema();
			this.SchemaEntries = _schema.SchemaEntries;
			this.SchemaGlobal = "dbo";
		}
		
		public override void FlushData() 	 
		{ 	 
			this._whereClause = null; 	 
			this._aggregateClause = null; 	 
			base.FlushData(); 	 
		}
			   
		/// <summary>
		/// Loads the business object with info from the database, based on the requested primary key.
		/// </summary>
		/// <param name="AdvID"></param>
		/// <returns>A Boolean indicating success or failure of the query</returns>
		public bool LoadByPrimaryKey(int AdvID)
		{
			switch(this.DefaultCommandType)
			{
				case CommandType.StoredProcedure:
					ListDictionary parameters = new ListDictionary();

					// Add in parameters
					parameters.Add(AdvSchema.AdvID.FieldName, AdvID);

					return base.LoadFromSql(this.SchemaStoredProcedureWithSeparator + "sp_GetAdv", parameters, CommandType.StoredProcedure);

				case CommandType.Text:
					this.Query.ClearAll();
					this.Where.WhereClauseReset();
					this.Where.AdvID.Value = AdvID;
					return this.Query.Load();

				default:
					throw new ArgumentException("Invalid CommandType", "commandType");
			}
		}
	
		/// <summary>
		/// Loads all records from the table.
		/// </summary>
		/// <returns>A Boolean indicating success or failure of the query</returns>
		public bool LoadAll()
		{
			switch(this.DefaultCommandType)
			{
				case CommandType.StoredProcedure:
					return base.LoadFromSql(this.SchemaStoredProcedureWithSeparator + "sp_GetAllAdv", null, CommandType.StoredProcedure);

				case CommandType.Text:
					this.Query.ClearAll();
					this.Where.WhereClauseReset();
					return this.Query.Load();

				default:
					throw new ArgumentException("Invalid CommandType", "commandType");
			}
		}

		/// <summary>
		/// Adds a new record to the internal table.
		/// </summary>
		public override void AddNew()
		{
			base.AddNew();
			this.ApplyDefaults();
		}

		/// <summary>
		/// Apply any default values to columns
		/// </summary>
		protected override void ApplyDefaults()
		{
		}

		protected override DbCommand GetInsertCommand(CommandType commandType)
		{	
			DbCommand dbCommand;

			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = GetDatabase();

			switch(commandType)
			{
				case CommandType.StoredProcedure:
					string sqlCommand = this.SchemaStoredProcedureWithSeparator + "sp_AddAdv";
					dbCommand = db.GetStoredProcCommand(sqlCommand);

					db.AddParameter(dbCommand, "AdvID", DbType.Int32, 0, ParameterDirection.Output, true, 0, 0, "AdvID", DataRowVersion.Default, Convert.DBNull);
					CreateParameters(db, dbCommand);
					
					return dbCommand;

				case CommandType.Text:
					this.Query.ClearAll();
					this.Where.WhereClauseReset();
					foreach(SchemaItem item in this.SchemaEntries)
					{
						if (!item.IsComputed)
						{
							if ((item.IsAutoKey && this.IdentityInsert) || !item.IsAutoKey)
							{
								this.Query.AddInsertColumn(item);
							}
						}
					}
					dbCommand = this.Query.GetInsertCommandWrapper();

					dbCommand.Parameters.Clear();
					if (this.IdentityInsert)
					{
						db.AddInParameter(dbCommand, "AdvID", DbType.Int32, "AdvID", DataRowVersion.Default);
					}
					else
					{
						db.AddParameter(dbCommand, "AdvID", DbType.Int32, 0, ParameterDirection.Output, true, 0, 0, "AdvID", DataRowVersion.Default, Convert.DBNull);
					}
					CreateParameters(db, dbCommand);

					return dbCommand;

				default:
					throw new ArgumentException("Invalid CommandType", "commandType");
			}
		}

		protected override DbCommand GetUpdateCommand(CommandType commandType)
		{
            DbCommand dbCommand;

			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = GetDatabase();

			switch(commandType)
			{
				case CommandType.StoredProcedure:
					string sqlCommand = this.SchemaStoredProcedureWithSeparator + "sp_UpdateAdv";
					dbCommand = db.GetStoredProcCommand(sqlCommand);

					db.AddInParameter(dbCommand, "AdvID", DbType.Int32, "AdvID", DataRowVersion.Current);
					CreateParameters(db, dbCommand);
					
					return dbCommand;

				case CommandType.Text:
					this.Query.ClearAll();
					foreach(SchemaItem item in this.SchemaEntries)
					{
						if (!(item.IsAutoKey || item.IsComputed))
						{
							this.Query.AddUpdateColumn(item);
						}
					}

					this.Where.WhereClauseReset();
					this.Where.AdvID.Operator = WhereParameter.Operand.Equal;
					dbCommand = this.Query.GetUpdateCommandWrapper();

					dbCommand.Parameters.Clear();
					CreateParameters(db, dbCommand);
					db.AddInParameter(dbCommand, "AdvID", DbType.Int32, "AdvID", DataRowVersion.Current);
					
					return dbCommand;

				default:
					throw new ArgumentException("Invalid CommandType", "commandType");
			}
		}

		protected override DbCommand GetDeleteCommand(CommandType commandType)
		{
            DbCommand dbCommand;

			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			Database db = GetDatabase();

			switch(commandType)
			{
				case CommandType.StoredProcedure:
					string sqlCommand = this.SchemaStoredProcedureWithSeparator + "sp_DeleteAdv";
					dbCommand = db.GetStoredProcCommand(sqlCommand);
					db.AddInParameter(dbCommand, "AdvID", DbType.Int32, "AdvID", DataRowVersion.Current);
					
					return dbCommand;

				case CommandType.Text:
					this.Query.ClearAll();
					this.Where.WhereClauseReset();
					this.Where.AdvID.Operator = WhereParameter.Operand.Equal;
					dbCommand = this.Query.GetDeleteCommandWrapper();

					dbCommand.Parameters.Clear();
					db.AddInParameter(dbCommand, "AdvID", DbType.Int32, "AdvID", DataRowVersion.Current);
					
					return dbCommand;

				default:
					throw new ArgumentException("Invalid CommandType", "commandType");
			}
		}

		private void CreateParameters(Database db, DbCommand dbCommand)
		{
			db.AddInParameter(dbCommand, "PartnerName", DbType.String, "PartnerName", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "Description", DbType.String, "Description", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "AdvURL", DbType.String, "AdvURL", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "AdvFile", DbType.String, "AdvFile", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "AdvTypeID", DbType.Int32, "AdvTypeID", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "AdvPositionID", DbType.Int32, "AdvPositionID", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "Status", DbType.Int32, "Status", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "Priority", DbType.Int32, "Priority", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "CreatedDate", DbType.Int32, "CreatedDate", DataRowVersion.Current);
			db.AddInParameter(dbCommand, "ExpiredDate", DbType.Int32, "ExpiredDate", DataRowVersion.Current);
		}
		
		#region Properties
		public virtual int AdvID
		{
			get
			{
				return this.GetInteger(AdvSchema.AdvID.FieldName);
	    	}
			set
			{
				this.SetInteger(AdvSchema.AdvID.FieldName, value);
			}
		}
		public virtual string PartnerName
		{
			get
			{
				return this.GetString(AdvSchema.PartnerName.FieldName);
	    	}
			set
			{
				this.SetString(AdvSchema.PartnerName.FieldName, value);
			}
		}
		public virtual string Description
		{
			get
			{
				return this.GetString(AdvSchema.Description.FieldName);
	    	}
			set
			{
				this.SetString(AdvSchema.Description.FieldName, value);
			}
		}
		public virtual string AdvURL
		{
			get
			{
				return this.GetString(AdvSchema.AdvURL.FieldName);
	    	}
			set
			{
				this.SetString(AdvSchema.AdvURL.FieldName, value);
			}
		}
		public virtual string AdvFile
		{
			get
			{
				return this.GetString(AdvSchema.AdvFile.FieldName);
	    	}
			set
			{
				this.SetString(AdvSchema.AdvFile.FieldName, value);
			}
		}
		public virtual int AdvTypeID
		{
			get
			{
				return this.GetInteger(AdvSchema.AdvTypeID.FieldName);
	    	}
			set
			{
				this.SetInteger(AdvSchema.AdvTypeID.FieldName, value);
			}
		}
		public virtual int AdvPositionID
		{
			get
			{
				return this.GetInteger(AdvSchema.AdvPositionID.FieldName);
	    	}
			set
			{
				this.SetInteger(AdvSchema.AdvPositionID.FieldName, value);
			}
		}
		public virtual int Status
		{
			get
			{
				return this.GetInteger(AdvSchema.Status.FieldName);
	    	}
			set
			{
				this.SetInteger(AdvSchema.Status.FieldName, value);
			}
		}
		public virtual int Priority
		{
			get
			{
				return this.GetInteger(AdvSchema.Priority.FieldName);
	    	}
			set
			{
				this.SetInteger(AdvSchema.Priority.FieldName, value);
			}
		}
		public virtual int CreatedDate
		{
			get
			{
				return this.GetInteger(AdvSchema.CreatedDate.FieldName);
	    	}
			set
			{
				this.SetInteger(AdvSchema.CreatedDate.FieldName, value);
			}
		}
		public virtual int ExpiredDate
		{
			get
			{
				return this.GetInteger(AdvSchema.ExpiredDate.FieldName);
	    	}
			set
			{
				this.SetInteger(AdvSchema.ExpiredDate.FieldName, value);
			}
		}

		public override string TableName
		{
			get { return "Adv"; }
		}
		
		#endregion		
		
		#region String Properties
		public virtual string s_AdvID
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.AdvID.FieldName) ? string.Empty : base.GetIntegerAsString(AdvSchema.AdvID.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.AdvID.FieldName);
			    else
			        this.AdvID = base.SetIntegerAsString(AdvSchema.AdvID.FieldName, value);
			}
		}
		public virtual string s_PartnerName
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.PartnerName.FieldName) ? string.Empty : base.GetStringAsString(AdvSchema.PartnerName.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.PartnerName.FieldName);
			    else
			        this.PartnerName = base.SetStringAsString(AdvSchema.PartnerName.FieldName, value);
			}
		}
		public virtual string s_Description
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.Description.FieldName) ? string.Empty : base.GetStringAsString(AdvSchema.Description.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.Description.FieldName);
			    else
			        this.Description = base.SetStringAsString(AdvSchema.Description.FieldName, value);
			}
		}
		public virtual string s_AdvURL
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.AdvURL.FieldName) ? string.Empty : base.GetStringAsString(AdvSchema.AdvURL.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.AdvURL.FieldName);
			    else
			        this.AdvURL = base.SetStringAsString(AdvSchema.AdvURL.FieldName, value);
			}
		}
		public virtual string s_AdvFile
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.AdvFile.FieldName) ? string.Empty : base.GetStringAsString(AdvSchema.AdvFile.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.AdvFile.FieldName);
			    else
			        this.AdvFile = base.SetStringAsString(AdvSchema.AdvFile.FieldName, value);
			}
		}
		public virtual string s_AdvTypeID
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.AdvTypeID.FieldName) ? string.Empty : base.GetIntegerAsString(AdvSchema.AdvTypeID.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.AdvTypeID.FieldName);
			    else
			        this.AdvTypeID = base.SetIntegerAsString(AdvSchema.AdvTypeID.FieldName, value);
			}
		}
		public virtual string s_AdvPositionID
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.AdvPositionID.FieldName) ? string.Empty : base.GetIntegerAsString(AdvSchema.AdvPositionID.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.AdvPositionID.FieldName);
			    else
			        this.AdvPositionID = base.SetIntegerAsString(AdvSchema.AdvPositionID.FieldName, value);
			}
		}
		public virtual string s_Status
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.Status.FieldName) ? string.Empty : base.GetIntegerAsString(AdvSchema.Status.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.Status.FieldName);
			    else
			        this.Status = base.SetIntegerAsString(AdvSchema.Status.FieldName, value);
			}
		}
		public virtual string s_Priority
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.Priority.FieldName) ? string.Empty : base.GetIntegerAsString(AdvSchema.Priority.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.Priority.FieldName);
			    else
			        this.Priority = base.SetIntegerAsString(AdvSchema.Priority.FieldName, value);
			}
		}
		public virtual string s_CreatedDate
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.CreatedDate.FieldName) ? string.Empty : base.GetIntegerAsString(AdvSchema.CreatedDate.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.CreatedDate.FieldName);
			    else
			        this.CreatedDate = base.SetIntegerAsString(AdvSchema.CreatedDate.FieldName, value);
			}
		}
		public virtual string s_ExpiredDate
		{
			get
			{
			    return this.IsColumnNull(AdvSchema.ExpiredDate.FieldName) ? string.Empty : base.GetIntegerAsString(AdvSchema.ExpiredDate.FieldName);
			}
			set
			{
			    if(string.Empty == value)
			        this.SetColumnNull(AdvSchema.ExpiredDate.FieldName);
			    else
			        this.ExpiredDate = base.SetIntegerAsString(AdvSchema.ExpiredDate.FieldName, value);
			}
		}
		#endregion		
	
		#region Where Clause
		public class WhereClause
		{
			public WhereClause(EasyObject entity)
			{
				this._entity = entity;
			}
			
			public TearOffWhereParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffWhereParameter(this);
					}

					return _tearOff;
				}
			}

			#region TearOff's
			public class TearOffWhereParameter
			{
				public TearOffWhereParameter(WhereClause clause)
				{
					this._clause = clause;
				}
				
				
				public WhereParameter AdvID
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.AdvID);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter PartnerName
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.PartnerName);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter Description
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.Description);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter AdvURL
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.AdvURL);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter AdvFile
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.AdvFile);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter AdvTypeID
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.AdvTypeID);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter AdvPositionID
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.AdvPositionID);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter Status
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.Status);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter Priority
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.Priority);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter CreatedDate
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.CreatedDate);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}

				public WhereParameter ExpiredDate
				{
					get
					{
							WhereParameter wp = new WhereParameter(AdvSchema.ExpiredDate);
							this._clause._entity.Query.AddWhereParameter(wp);
							return wp;
					}
				}


				private WhereClause _clause;
			}
			#endregion
		
			public WhereParameter AdvID
		    {
				get
		        {
					if(_AdvID_W == null)
	        	    {
						_AdvID_W = TearOff.AdvID;
					}
					return _AdvID_W;
				}
			}

			public WhereParameter PartnerName
		    {
				get
		        {
					if(_PartnerName_W == null)
	        	    {
						_PartnerName_W = TearOff.PartnerName;
					}
					return _PartnerName_W;
				}
			}

			public WhereParameter Description
		    {
				get
		        {
					if(_Description_W == null)
	        	    {
						_Description_W = TearOff.Description;
					}
					return _Description_W;
				}
			}

			public WhereParameter AdvURL
		    {
				get
		        {
					if(_AdvURL_W == null)
	        	    {
						_AdvURL_W = TearOff.AdvURL;
					}
					return _AdvURL_W;
				}
			}

			public WhereParameter AdvFile
		    {
				get
		        {
					if(_AdvFile_W == null)
	        	    {
						_AdvFile_W = TearOff.AdvFile;
					}
					return _AdvFile_W;
				}
			}

			public WhereParameter AdvTypeID
		    {
				get
		        {
					if(_AdvTypeID_W == null)
	        	    {
						_AdvTypeID_W = TearOff.AdvTypeID;
					}
					return _AdvTypeID_W;
				}
			}

			public WhereParameter AdvPositionID
		    {
				get
		        {
					if(_AdvPositionID_W == null)
	        	    {
						_AdvPositionID_W = TearOff.AdvPositionID;
					}
					return _AdvPositionID_W;
				}
			}

			public WhereParameter Status
		    {
				get
		        {
					if(_Status_W == null)
	        	    {
						_Status_W = TearOff.Status;
					}
					return _Status_W;
				}
			}

			public WhereParameter Priority
		    {
				get
		        {
					if(_Priority_W == null)
	        	    {
						_Priority_W = TearOff.Priority;
					}
					return _Priority_W;
				}
			}

			public WhereParameter CreatedDate
		    {
				get
		        {
					if(_CreatedDate_W == null)
	        	    {
						_CreatedDate_W = TearOff.CreatedDate;
					}
					return _CreatedDate_W;
				}
			}

			public WhereParameter ExpiredDate
		    {
				get
		        {
					if(_ExpiredDate_W == null)
	        	    {
						_ExpiredDate_W = TearOff.ExpiredDate;
					}
					return _ExpiredDate_W;
				}
			}

			private WhereParameter _AdvID_W = null;
			private WhereParameter _PartnerName_W = null;
			private WhereParameter _Description_W = null;
			private WhereParameter _AdvURL_W = null;
			private WhereParameter _AdvFile_W = null;
			private WhereParameter _AdvTypeID_W = null;
			private WhereParameter _AdvPositionID_W = null;
			private WhereParameter _Status_W = null;
			private WhereParameter _Priority_W = null;
			private WhereParameter _CreatedDate_W = null;
			private WhereParameter _ExpiredDate_W = null;

			public void WhereClauseReset()
			{
				_AdvID_W = null;
				_PartnerName_W = null;
				_Description_W = null;
				_AdvURL_W = null;
				_AdvFile_W = null;
				_AdvTypeID_W = null;
				_AdvPositionID_W = null;
				_Status_W = null;
				_Priority_W = null;
				_CreatedDate_W = null;
				_ExpiredDate_W = null;

				this._entity.Query.FlushWhereParameters();

			}
	
			private EasyObject _entity;
			private TearOffWhereParameter _tearOff;
			
		}
	
		public WhereClause Where
		{
			get
			{
				if(_whereClause == null)
				{
					_whereClause = new WhereClause(this);
				}
		
				return _whereClause;
			}
		}
		
		private WhereClause _whereClause = null;	
		#endregion
		
		#region Aggregate Clause
		public class AggregateClause
		{
			public AggregateClause(EasyObject entity)
			{
				this._entity = entity;
			}
			
			public TearOffAggregateParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffAggregateParameter(this);
					}

					return _tearOff;
				}
			}

			#region TearOff's
			public class TearOffAggregateParameter
			{
				public TearOffAggregateParameter(AggregateClause clause)
				{
					this._clause = clause;
				}
				
				
				public AggregateParameter AdvID
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.AdvID);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter PartnerName
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.PartnerName);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter Description
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.Description);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter AdvURL
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.AdvURL);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter AdvFile
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.AdvFile);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter AdvTypeID
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.AdvTypeID);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter AdvPositionID
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.AdvPositionID);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter Status
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.Status);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter Priority
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.Priority);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter CreatedDate
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.CreatedDate);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}

				public AggregateParameter ExpiredDate
				{
					get
					{
							AggregateParameter ap = new AggregateParameter(AdvSchema.ExpiredDate);
							this._clause._entity.Query.AddAggregateParameter(ap);
							return ap;
					}
				}


				private AggregateClause _clause;
			}
			#endregion
		
			public AggregateParameter AdvID
		    {
				get
		        {
					if(_AdvID_W == null)
	        	    {
						_AdvID_W = TearOff.AdvID;
					}
					return _AdvID_W;
				}
			}

			public AggregateParameter PartnerName
		    {
				get
		        {
					if(_PartnerName_W == null)
	        	    {
						_PartnerName_W = TearOff.PartnerName;
					}
					return _PartnerName_W;
				}
			}

			public AggregateParameter Description
		    {
				get
		        {
					if(_Description_W == null)
	        	    {
						_Description_W = TearOff.Description;
					}
					return _Description_W;
				}
			}

			public AggregateParameter AdvURL
		    {
				get
		        {
					if(_AdvURL_W == null)
	        	    {
						_AdvURL_W = TearOff.AdvURL;
					}
					return _AdvURL_W;
				}
			}

			public AggregateParameter AdvFile
		    {
				get
		        {
					if(_AdvFile_W == null)
	        	    {
						_AdvFile_W = TearOff.AdvFile;
					}
					return _AdvFile_W;
				}
			}

			public AggregateParameter AdvTypeID
		    {
				get
		        {
					if(_AdvTypeID_W == null)
	        	    {
						_AdvTypeID_W = TearOff.AdvTypeID;
					}
					return _AdvTypeID_W;
				}
			}

			public AggregateParameter AdvPositionID
		    {
				get
		        {
					if(_AdvPositionID_W == null)
	        	    {
						_AdvPositionID_W = TearOff.AdvPositionID;
					}
					return _AdvPositionID_W;
				}
			}

			public AggregateParameter Status
		    {
				get
		        {
					if(_Status_W == null)
	        	    {
						_Status_W = TearOff.Status;
					}
					return _Status_W;
				}
			}

			public AggregateParameter Priority
		    {
				get
		        {
					if(_Priority_W == null)
	        	    {
						_Priority_W = TearOff.Priority;
					}
					return _Priority_W;
				}
			}

			public AggregateParameter CreatedDate
		    {
				get
		        {
					if(_CreatedDate_W == null)
	        	    {
						_CreatedDate_W = TearOff.CreatedDate;
					}
					return _CreatedDate_W;
				}
			}

			public AggregateParameter ExpiredDate
		    {
				get
		        {
					if(_ExpiredDate_W == null)
	        	    {
						_ExpiredDate_W = TearOff.ExpiredDate;
					}
					return _ExpiredDate_W;
				}
			}

			private AggregateParameter _AdvID_W = null;
			private AggregateParameter _PartnerName_W = null;
			private AggregateParameter _Description_W = null;
			private AggregateParameter _AdvURL_W = null;
			private AggregateParameter _AdvFile_W = null;
			private AggregateParameter _AdvTypeID_W = null;
			private AggregateParameter _AdvPositionID_W = null;
			private AggregateParameter _Status_W = null;
			private AggregateParameter _Priority_W = null;
			private AggregateParameter _CreatedDate_W = null;
			private AggregateParameter _ExpiredDate_W = null;

			public void AggregateClauseReset()
			{
				_AdvID_W = null;
				_PartnerName_W = null;
				_Description_W = null;
				_AdvURL_W = null;
				_AdvFile_W = null;
				_AdvTypeID_W = null;
				_AdvPositionID_W = null;
				_Status_W = null;
				_Priority_W = null;
				_CreatedDate_W = null;
				_ExpiredDate_W = null;

				this._entity.Query.FlushAggregateParameters();

			}
	
			private EasyObject _entity;
			private TearOffAggregateParameter _tearOff;
			
		}
	
		public AggregateClause Aggregate
		{
			get
			{
				if(_aggregateClause == null)
				{
					_aggregateClause = new AggregateClause(this);
				}
		
				return _aggregateClause;
			}
		}
		
		private AggregateClause _aggregateClause = null;	
		#endregion
	}
}
